<h3><?php echo $dataProvider->itemCount; ?> <?php echo Lang::t('comment.page.title'); ?></h3>

<div class="comments">

<?php if(Yii::app()->user->isGuest && !$dataProvider->itemCount): ?>
    <div class="item">
        No comment, please log in to leave comment.
    </div>
<?php endif; ?>
    
<?php foreach($dataProvider->data as $data): ?>
<?php $data->creator->defaultImage=array(Option::GENDER_MALE=>$this->imagesPath.'/male.gif', Option::GENDER_FEMALE=>$this->imagesPath.'/female.gif'); ?>

    <div class="item">G
        <div class="user">
            <img src="<?php echo $data->creatorSquareAvatar; ?>" alt="<?php echo $data->creatorName; ?>" width="30" height="40" />
        </div>
        <div class="message">
            <strong><?php echo $data->creatorName; ?></strong> . <?php echo date('Y-M-d H:i:s', $data->createdTime); ?> . <?php echo $data->createdTimeAgo; ?>
            <p><?php echo $data->message; ?></p>
        </div>
    </div>

<?php endforeach; ?>

<?php if(!Yii::app()->user->isGuest): ?>
<?php Yii::app()->user->defaultImage=array(Option::GENDER_MALE=>$this->imagesPath.'/male.gif', Option::GENDER_FEMALE=>$this->imagesPath.'/female.gif'); ?>
    <div class="item">
        <div class="user">
            <img src="<?php echo Yii::app()->user->squareAvatar; ?>" alt="<?php echo Yii::app()->user->displayName; ?>" width="50" height="50" />
        </div>
        <div class="message">
            <?php $form = $this->beginWidget('ActiveForm', $formConfig); ?>
            <?php echo $form->alert($model, array(
                'errorMessageHtmlOptions'=>array('class'=>'alert alert-danger'),
                'flashHtmlOptions'=>array('class'=>'alert alert-'),
            )); ?>
            
            <?php echo $form->textArea($model, 'message_', array('rows' => 6, 'cols' => 100)); ?>
            <div class="buttons">
                <?php echo CHtml::submitButton(Lang::t('comment.btn.submit')); ?>
            </div>
            <?php $this->endWidget(); ?>
        </div>
    </div>
<?php endif; ?>
</div><!--comments-->